Monkey patch faraday to fix encoding issue in URLs

Using binary encoding allows the URL to contain characters that are not UTF-8 encoded.

 #1588

Dominik Sander 8 年之前
父节点
当前提交
5c53e660a8
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      config/initializers/faraday_patch.rb

+ 11 - 0
config/initializers/faraday_patch.rb

@@ -0,0 +1,11 @@
1
+# Monkey patch https://github.com/lostisland/faraday/pull/513
2
+# Fixes encoding issue when passing an URL with non UTF-8 characters
3
+module Faraday
4
+  module Utils
5
+    def unescape(s)
6
+      string = s.to_s
7
+      string.force_encoding(Encoding::BINARY) if RUBY_VERSION >= '1.9'
8
+      CGI.unescape string
9
+    end
10
+  end
11
+end